package com.klangner.animation
{
  import com.klangner.animation.path.EllipticalPath;
  import com.klangner.animation.path.RectanglePath;
  import com.klangner.animation.path.VerticalSpringPath;
  import com.klangner.animation.sprites.Arrow;
  import com.klangner.animation.sprites.Ball;
  import com.klangner.animation.sprites.GradientBox;
  import com.klangner.animation.sprites.ImageSprite;
  import com.klangner.animation.sprites.MovableSprite;
  import com.klangner.animation.sprites.MultiCurve;
  
  import flash.events.Event;
  
  import mx.containers.Canvas;

  public class SceneView extends Canvas
  {

    private var ball:Ball;
    private var arrow:Arrow;
    private var box:GradientBox;
    private var multiCurve:MultiCurve;
    private var image:ImageSprite;
    private var movableObjects:Array = new Array();

    
    public function SceneView(){
      super();
      
    }
    
    public function init():void{
      
      box = new GradientBox(new VerticalSpringPath(width-200, height/2, height/5));
      movableObjects.push(box);
      this.rawChildren.addChild(box);

      arrow = new Arrow(new RectanglePath(100, 100, width-200, height-200));
      movableObjects.push(arrow);
      this.rawChildren.addChild(arrow);

      ball = new Ball(new VerticalSpringPath(200, height/2, height/5));
      ball.color = 0x00ff00;
      movableObjects.push(ball);
      this.rawChildren.addChild(ball);

      multiCurve = new MultiCurve(null);
      movableObjects.push(multiCurve);
      this.rawChildren.addChild(multiCurve);

      image = new ImageSprite(new EllipticalPath(200, 200));
      movableObjects.push(image);
      this.rawChildren.addChild(image);

//      this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
      this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
    
//    private function onMouseDown(event:MouseEvent):void {
//    }
    
    private function onEnterFrame(event:Event):void {

      for each(var sprite:MovableSprite in movableObjects){
        sprite.move();
      }
    }

  }
}